package com.fjp.heartguard.app.weight.pop

import android.content.Context
import android.widget.Button
import android.widget.TextView
import com.fjp.heartguard.R
import com.fjp.heartguard.app.data.bean.CredentialFile
import com.lxj.xpopup.core.CenterPopupView

class EditCertificatePop(context: Context, var credentialFile: CredentialFile, var index: Int, var listener: Listener) : CenterPopupView(context) {
    lateinit var nameTv: TextView

    interface Listener {
        fun onclickDelete(index: Int)
        fun onclickSave(name: String)
    }

    override fun getImplLayoutId(): Int {
        return R.layout.pop_edit_certificate
    }

    override fun onCreate() {
        super.onCreate()
        findViewById<TextView>(R.id.deleteTv).setOnClickListener {
            dismiss()
            listener.onclickDelete(index)
        }
        findViewById<Button>(R.id.laterBtn).setOnClickListener { dismiss() }
        findViewById<Button>(R.id.saveBtn).setOnClickListener {
            listener.onclickSave(nameTv.text.toString())
            dismiss()
        }
        nameTv = findViewById<TextView>(R.id.nameEt)
        nameTv.text = credentialFile.name
    }
}